package com.tgr.shortLink.admin.remote;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.TypeReference;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tgr.shortLink.admin.common.context.BaseContext;
import com.tgr.shortLink.admin.common.convention.result.Result;
import com.tgr.shortLink.admin.remote.dto.req.*;
import com.tgr.shortLink.admin.remote.dto.resp.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@FeignClient(value="shortLink-project",url = "${aggregation.remote-url:}")
public interface ShortLinkActualRemoteService {

    /**
     * 短链接远程调用创建短链接功能
         * @param requestParam
          * @return
          */
    @PostMapping("/api/short-link/link/v1/create")
    Result<LinkCreateRespDTO> createLink(@RequestBody LinkCreateReqDTO requestParam);

    /**
     * 短链接远程调用分页服务
     * @param
     * @return
     */
    @GetMapping("/api/short-link/link/v1/page")
    Result<Page<LinkPageRespDTO>> pageLink(@RequestParam("gid") String gid,
                                           @RequestParam("current") Long current,
                                           @RequestParam("size") Long size);

    /**
     * 短链接远程调用查询分组内短链接个数
     */
    @GetMapping("/api/short-link/link/v1/count")
    Result<List<LinkGroupQueryRespDTO>> linkCountQuery(@RequestParam("gid") List<String> requestParam);

    /**
     * 短链接远程调用修改短链接功能
     */
    @PostMapping("/api/short-link/link/v1/update")
    void updateLink(@RequestBody LinkUpdateReqDTO requestParam);

    @GetMapping("/api/short-link/link/v1/title")
    Result<String> getLinkTitle(@RequestParam("url") String url);

    @PostMapping("/api/short-link/v1/recycle-bin/save")
    void saveBin(@RequestBody RecycleBinSaveReqDTO requestParam);


    @GetMapping("/api/short-link/v1/recycle-bin/page")
    Result<IPage<RecycleBinPageRespDTO>> pageBin(@SpringQueryMap RecycleBinPageReqDTO requestParam);
    @PostMapping("/api/short-link/v1/recycle-bin/recover")
    void recoverBin(RecycleBinRecoverReqDTO requestParam);

    @PostMapping("/api/short-link/v1/recycle-bin/remove")
    void removeBin(RecycleBinRemoveReqDTO requestParam);

    @GetMapping("/api/short-link/v1/stats")
    Result<LinkStatsRespDTO> oneShortLinkStats(
            @RequestParam("fullShortUrl") String fullShortUrl,
            @RequestParam("gid") String gid,
            @RequestParam("startDate") String startDate,
            @RequestParam("endDate") String endDate);

    @GetMapping("/api/short-link/v1/stats/access-record")
    Result<Page<LinkStatsAccessRecordRespDTO>> linkStatsAccessRecord(@SpringQueryMap LinkStatsAccessRecordReqDTO requestParam);
}
